﻿using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
using DaInterFace;
using DaInterFace.Mobile;

namespace DaFunction.Mobile
{
    internal class Mobile : IMobile
    {
        public event MobileMessageHandler MessageEvent;

        public IDataBase Data { get { return data; } }
        public IEncrypt Encrypt { get { return encrypt; } }
        public IJson Json { get { return json; } }
        public IConfig Config { get { return config; } }
        public IClientMessage ClientMessage { get { return clientMessage; } }

        private IDataBase data;
        private IEncrypt encrypt;
        private IJson json;
        private IConfig config;
        private IClientMessage clientMessage;

        public Mobile(IDataBase data, IConfig config)
        {
            this.data = data;
            this.encrypt = new MobileEncrypt();
            this.json = new MobileJson();
            this.config = new MobileConfig(config);
            this.clientMessage = new MobileClientMessage();
        }

        public void Message(MessageType type, String note)
        {
            Message(type, note, 0);
        }

        public void Message(MessageType type, String note, Double span)
        {
            if (MessageEvent != null)
            {
                MessageEvent.Invoke(type, note, span);
            }
        }
    }
}